import request from './request'
import { _isDev } from './config'


//  生产环境还需要区分正式站测试站
const uni = _isDev ? '53' : process.env.NODE_ENV === 'development' ? 33 : 33;

export const getBanner = async () => {
  // 获取banner
  let res = await request({
    params: {
      action: 'banner'
    },
    data: { uniacid: uni }
  });
  return res.data
}


export const getNotices = async () => {
  // 获取公告列表
  let res = await request({
    params: {
      action: 'notices'
    },
    data: { uniacid: uni }
  });
  return res.data
}


export const getNoticesPvuv = async (noticeid) => {
  // 公告点击pvuv
  let res = await request({
    params: {
      action: 'notices_pvuv'
    },
    data: { uniacid: uni, noticeid: noticeid }
  });
  return res.data
}


export const getHomeGoodsList = async (config) => {
  // 获取首页商品数据
  let res = await request({
    params: {
      action: 'get_index_goods'
    },
    data: config
  });
  return res.data;
}

export const createPurchaseOrder = (config) => {
  //  buy 1 购买 创建采购订单 
  //  buy 0 查询规格
  return request({
    params: {
      action: 'caigou'
    },
    data: config
  })
}

// export const handelPurchaseOrder = (config) => {
//   //  buy 1 购买 创建采购订单 
//   //  buy 0 查询规格
//   return request({
//     params: {
//       action: 'caigou'
//     },
//     data: config
//   })
// }

export const updateOption = (config) => (
  //  更新商品规格
  request({
    params: {
      action: 'caigou'
    },
    data: config
  })
)

export const getGoodsDetail = (config) => (
  // 获取商品详情
  request({
    params: {
      action: 'get_goods_info'
    },
    data: config
  })
)

export const getServiceInfo = config => (
  // 获取服务说明
  request({
    params: {
      action: 'get_services'
    },
    data: config
  })
)

export const updateOrderAddress = config => (
  // 修改订单地址
  // 详细咨询后端
  request({
    params: {
      action: 'update_order_address'
    },
    data: config
  })
)

export const getCategoryList = config => (
  // 获取分类数据
  request({
    params: {
      action: 'getcategory'
    },
    data: config
  })
)

export const getCategoryGoodsList = (config) => {
  // 获取分类商品列表
  return request({
    params: {
      action: 'get_index_goods'
    },
    data: config
  });
}






